let chatPeople=document.getElementsByClassName("chatPeople");
let chatRoomRight=document.getElementsByClassName("chatRoomRight")[0];
let emptyChat=document.getElementsByClassName("emptyChat")[0];
let toChat=document.getElementsByClassName("toChat");
let roomNumber=document.getElementsByClassName("roomNumber")[0];
//昵称
let chatBoxTop=document.getElementsByClassName("chatBoxTop");
//聊天时的昵称
let chatHead=document.getElementsByClassName("chatHead");
//聊天内容
let chat=document.getElementsByClassName("chat");
// function chatRoom(){
//     var chatBox=document.createElement("div");
//     chatBox.className="chatBox";
// }
for(let i=0;i<chatPeople.length;i++){
    chatPeople[i].onclick=function(){
        // emptyChat.remove();
        for(let j=0;j<chatPeople.length;j++){
            chatPeople[j].style.backgroundColor="skyblue";
        }
        chatPeople[i].style.backgroundColor="#0095d9";
        toChat[i].style.display="block";
        CHAT(roomNumber[i].value);
        function CHAT(i){
            $.ajax({
                url:"../message/messages",
                type:"get",
                data:{
                    roomNumber:i,
                },
                success:function(data){
                    chatHead[i].innerHTML=data.data.chatAccountName;
                    chat[i].innerHTML=data.data.messages;
                }
            })
        }

    }
}